import {create} from 'zustand';
import {Coordinate, LocationAction, LocationState} from './type';

export const useLocationStore = create<LocationState & LocationAction>(set => ({
  coordinate: {altitude: 0, longitude: 0},
  addressName: '四川成都',
  regionName: '四川',
  setRegionName: (regionName: string) => {
    set(() => ({
      regionName,
    }));
  },
  setCoordinate: (coordinate: Coordinate) => {
    set(() => ({coordinate}));
  },
  setAddressName: (addressName: string) => {
    set(() => ({addressName}));
  },
}));
